/*
 * -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
 *
 *      Filename : progbar.h
 *   Description : 
 *
 *       Version : 1.0
 *         CTime : Wed Nov 30 10:55:26 CST 2016
 *      Compiler : g++
 *        Author : Gallen Calade
 *        E-mail : 932441619@qq.com
 *
 * -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
 */

#ifndef PROGBAR_H
#define PROGBAR_H

#include <string>
#include <cstring>

#define PROG_NUM_STYLE      0       // number style     : 40%
#define PROG_CHR_STYLE      1       // character style  : [####      ]%40
#define PROG_BGC_STYLE      2       // background color style :

#define PROG_MAX_LEN        80      // this is the length of progress when get 100%

template <typename T>
class CProgBar {
public:
    CProgBar() = default;

    ~CProgBar()
    {
        printf("\n");
        delete[] prog;
        prog = nullptr;
    }

    void init();
    
    void setTitle(std::string t) { title = t; }
    void setChr(char c) { chr = c; }
    void setStyle(int s) { style = s; }
    void setRange(T r) { range = r; }
    void setNote(std::string n) { note = n; }

    void setpos(T pos);

private:
    char    chr = '#';
    std::string title = "TITLE ";
    std::string note = " NOTE";
    int     style = PROG_BGC_STYLE;
    T       range = 100;
    double  offset = 100 / (double)PROG_MAX_LEN;
    double  multiPower = 1;
    char*   prog = nullptr;
};

template class CProgBar<int>;
template class CProgBar<long>;
template class CProgBar<long long>;

#endif  // PROGBAR_H
